<template>
  <div>
    <Frame
      class="frame"
      size="middle-2"
      title="设备详情"
      :visible="dialogVisible"
    >
      <template #default>
        <el-table
          :data="alarmData"
          height="calc(100% - 50px)"
          class="table"
          :header-cell-style="headerStyle"
          row-key="id"
          ref="refMultipleTable"
        >
          <el-table-column align="center" label="序号" type="index" width="50">
          </el-table-column>
          <el-table-column
            align="center"
            prop="imei"
            label="设备编码"
            min-width="120"
            show-overflow-tooltip
          >
          </el-table-column>
           <el-table-column
            align="center"
            prop="orgName"
            label="联网单位"
            min-width="100"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="spaceName"
            label="安装点"
            min-width="100"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="installTime"
            label="安装时间"
            min-width="110"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="management"
            label="操作"
            width="80"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <div
                class="table-body-item-btn"
                @click="onBinding(scope.row)"
              >
                <span class="btn-view">绑定</span>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div class="paging">
          <Pagination
            :page.sync="page"
            :limit.sync="limit"
            :total="total"
            :pagerCount="5"
            @pagination="getList"
            class="pagination"
          >
          </Pagination>
        </div>
      </template>
      <template #footer>
        <div class="footer-btns">
          <el-button size="small" @click="closeDialog">关闭</el-button>
        </div>
      </template>
    </Frame>
  </div>
</template>

<script>
import { reqPageRommDevice } from "@api/api.js";
import { mapState } from "vuex";
import Frame from "./frame.vue";
import Pagination from "@components/Pagination.vue";
import tableStyleMixin from "@mixin/table-style";

export default {
  props: ["fcInfo"],
  components: { Frame, Pagination },
    mixins: [tableStyleMixin],
  data() {
    return {
      dialogVisible: false,
      page: 1,
      limit: 10,
      total: 0,
      alarmData:[],
    };
  },
  watch: {
    dialogVisible(e){
        if(e){
            this.getList()
        }
    }
  },
  computed: {
    ...mapState(["user"]),
  },
  mounted() {},
  methods: {
    onBinding(e){
        this.$parent.getBinding('是否绑定到该设备','1',e)
    },
    // 获取列表
    async getList() {
      let res = await reqPageRommDevice(this.page, this.limit, {
        roomId: this.fcInfo.id,
        deviceType: 'Camera',
        deviceCode: '',
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);

      this.total = res.data.total || 0;
      this.alarmData = res.data.rows || [];
    },
    // 点击关闭弹框
    closeDialog() {
      this.dialogVisible = false;
    },
  },
};
</script>

<style lang="less" scoped>
@import url("../../../../views/common.less");

.footer-btns {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.content {
  color: #fff;
  padding: 0 8vw;
}

// 列表
::v-deep .el-table {
  background: transparent !important;
}
::v-deep .el-table tr {
  background: transparent !important;
}

// 分页器
.paging {
  width: 100%;

  ::v-deep .el-pagination {
    height: 50px;
    background: transparent;
  }

  ::v-deep .el-pager {
    background: transparent !important;
  }

  ::v-deep .el-pager li {
    border-radius: 30px;
    // background: #0d2a8c !important;
    // color: #fff;
    background: rgba(16, 58, 95, 0.8) !important; /* 深海蓝 */
    border: 1px solid #2a8bf2 !important; /* 科技蓝边框 */
    color: #e0f2fe !important; /* 浅蓝文字 */
  }

  ::v-deep .el-pager li.active {
    // background: #114683 !important;
    // border: 1px solid #01eafc;
    // box-sizing: border-box;
    // color: #01eafc;
    // box-shadow: inset 0 0 2px rgba(1, 234, 252, 1);
    background: #2a8bf2 !important; /* 高亮科技蓝 */
    color: #001a33 !important; /* 深色文字提升对比度 */
    font-weight: bold;
    box-shadow: 0 0 8px rgba(42, 139, 242, 0.6); /* 发光效果 */
  }

  /* 悬停效果 */
  .el-pager li:hover,
  .el-pagination button:hover {
    background: #1a5f9c !important;
    transform: translateY(-1px);
    transition: all 0.3s;
  }

  /* 总记录数文字 */
  ::v-deep .el-pagination__total {
    color: #a7c4dc !important; /* 浅灰蓝 */
    font-size: 13px;
  }
  /* 页码输入框 */
  .el-pagination .el-input__inner {
    background: rgba(16, 58, 95, 0.5) !important;
    border-color: #2a8bf2 !important;
    color: #fff !important;
  }

  ::v-deep .el-pagination .btn-prev {
    background: #0d2a8c;
  }

  ::v-deep .btn-prev .el-icon {
    color: #fff;
  }

  ::v-deep .el-pagination .btn-next {
    background: #0d2a8c;
  }

  ::v-deep .btn-next .el-icon {
    color: #fff;
  }
}
.table-body-item-btn {
  flex: 1;
  text-align: right;
  white-space: nowrap;
  padding-right: 16px;
  .btn-view {
    background: linear-gradient(
      90deg,
      #2f5da3 0%,
      rgba(47, 93, 163, 0.35) 100%
    );
    box-shadow: inset 0px 3px 10px 1px rgba(47, 93, 163, 0.47);
    border-radius: 2px 2px 2px 2px;
    border: 1px solid #658cc7;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 12px;
    color: #d2e1fe;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 2px;
  }
}
</style>
